import 'package:app/common/colors.dart';
import 'package:app/common/tool.dart';
import 'package:app/components/base_scaffold_appbar.dart';
import 'package:app/components/mine_webview.dart';
import 'package:app/components/my_webview.dart';
import 'package:app/services/dio_manager.dart';
import 'package:app/utils/hexcolor.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';

class ManageAboutUs extends StatefulWidget {
  @override
  _ManageAboutUsState createState() => _ManageAboutUsState();
}

class _ManageAboutUsState extends State<ManageAboutUs>
    with TickerProviderStateMixin {
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getVersion();

  }
  var packageName;

  var version;
  getVersion()async{
    PackageInfo packageInfo = await PackageInfo.fromPlatform();
    String _packageName = packageInfo.packageName;
    String _version = packageInfo.version;
    version = _version;
    packageName = _packageName;
    setState(() {

    });
  }




  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar:BaseAppBar(child: Text('关于我们'),
          preferredSize: Size(Get.width, AppTool.appBarHEIGHT),),
        // AppBar(
        //     leading: IconButton(
        //       onPressed: () {
        //         Get.back();
        //       },
        //       icon: Image.asset(
        //         'images/leftarr.png',
        //         color: Colors.white,
        //         width: 15,
        //         height: 15,
        //       ),
        //     ),
        //     title: const Text(
        //       '关于我们',
        //       style: TextStyle(
        //         color: Colors.white,
        //       ),
        //     ),
        //     backgroundColor: Colors.black), // 就是这里
        body: Container(
            color: AppColor.bgColor,
            padding: const EdgeInsets.all(0.0),
            child: Column(
              children: [
                Container(
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(0),
                    ),
                  padding: const EdgeInsets.all(0.0),
                  child:  Center(
                    child: Container(
                        alignment: Alignment.center,
                        padding: const EdgeInsets.only(top: 25,bottom: 50),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Container(
                                child: Image.asset(
                                    'images/logo.png',
                                    width: 120,
                                    height: 120)),
                            SizedBox(height: 15,),
                            Container(
                                child: Text("DTCloudApp V${version}",
                                    style: TextStyle(
                                        color: AppColor.themeColor,
                                        fontSize: 20,
                                        fontWeight:
                                        FontWeight.bold)))
                          ],
                        )),
                  ),),

                Container(
                    margin: const EdgeInsets.only(top: 20),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(8),
                    ),
                    padding: const EdgeInsets.all(0.0),
                    child: Container(
                        padding: const EdgeInsets.all(0.0),
                        child: Column(
                          children: [
                            GestureDetector(
                                onTap: () {
                                  Get.to(MineWebView('用户协议',
                                      'http://portal.xumengte.com/taro-vue/active/memaifree.html'));
                                },
                                child: Container(
                                  height: 55,
                                  color: Colors.white,
                                  padding: EdgeInsets.only(left: 15,right: 15),
                                  child: Row(
                                    mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                    children: [
                                      Container(child: const Text("用户协议")),
                                      Container(
                                        child: const Icon(
                                          color: Colors.grey,
                                          Icons.arrow_forward_ios,
                                          size: 15,
                                        ),
                                      )
                                    ],
                                  ),
                                )),
                            GestureDetector(
                                onTap: () {
                                  Get.to(MineWebView('开发者信息',
                                      'http://portal.xumengte.com/taro-vue/active/memaifree.html'));
                                },
                                child: Container(
                                  height: 55,
                                  color: Colors.white,
                                  padding: EdgeInsets.only(left: 15,right: 15),
                                  child: Row(
                                    mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                    children: [
                                      Container(child: const Text("开发者信息")),
                                      Container(
                                        child: const Icon(
                                          color: Colors.grey,
                                          Icons.arrow_forward_ios,
                                          size: 15,
                                        ),
                                      )
                                    ],
                                  ),
                                )),
                            GestureDetector(
                                onTap: () async{
                                  PackageInfo packageInfo = await PackageInfo.fromPlatform();
                                  String packageName = packageInfo.packageName;
                                  String version = packageInfo.version;
                                  // botToast.showText(text: version);
                                  BotToast.showText(text: '已是最新版本');

                                  // Get.to(MineWebView('开发者信息',
                                  //     'http://portal.xumengte.com/taro-vue/active/memaifree.html'));
                                },
                                child: Container(
                                  height: 55,
                                  color: Colors.white,
                                  padding: EdgeInsets.only(left: 15,right: 15),
                                  child: Row(
                                    mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                    children: [
                                      Container(child: const Text("版本检测")),
                                      Container(
                                        child: const Icon(
                                          color: Colors.grey,
                                          Icons.arrow_forward_ios,
                                          size: 15,
                                        ),
                                      )
                                    ],
                                  ),
                                ))
                          ],
                        )),),
              ],
            )));
  }
}
